package com.service;

import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;

public class Httpclient
{
	public static void main(String args[])
	{
		Httpclient Httpclient = new Httpclient();
		try
		{
			Httpclient.getHttpClientResult();
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	private void getHttpClientResult() throws Exception
	{
		// 鍒濆鍖栵紝姝ゅ鏋勯�鍑芥暟灏变笌3.1涓笉鍚�
		HttpClient client = new DefaultHttpClient();
		// HttpPost httpost = new
		// HttpPost("http://127.0.0.1:8080/WebRoot/continueBook");
		// HttpPost httpost = new
		// HttpPost("http://127.0.0.1:8080/WebRoot/OthersRead");
		// HttpPost httpost = new
		// HttpPost("http://192.168.1.107:8080/WebRoot/select");
		// HttpPost httpost = new
		// HttpPost("http://127.0.0.1:8080/WebRoot/readBook");
		 HttpPost httpost = new
		 HttpPost("http://127.0.0.1:8082/kuaidi/updateUser");
	//	HttpPost httpost = new HttpPost("http://127.0.0.1:8080/AutionDB/login");
		List params = new ArrayList();
		HttpEntity entity = null;
		HttpResponse response = null;
		// params.add(new BasicNameValuePair("Url", "9787121115349"));
		 //params.add(new BasicNameValuePair("UserId", "1"));
		// params.add(new BasicNameValuePair("Url", "238"));
		 //params.add(new BasicNameValuePair("user", "mysql"));
		 //params.add(new BasicNameValuePair("pass", "mysql"));
		//WebRoot params.add(new BasicNameValuePair("BookCode", "100000000"));
		params.add(new BasicNameValuePair("UserName", "111"));
		params.add(new BasicNameValuePair("UserPassword", "123"));
		params.add(new BasicNameValuePair("NewPassword", "12"));
		httpost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
		response = client.execute(httpost);
		response.getStatusLine().getStatusCode();
		entity = response.getEntity();
		// 鍙互璁剧疆澶氫釜鍙傛暟
		System.out.println(response.getStatusLine().getStatusCode());
	}
}
